/**
 * 获取 navbar 详细数据
 * @returns {Object} navbarState
 * @returns {Number} navbarState.statusBarHeight - 状态栏高度
 * @returns {Number} navbarState.menubarHeight - menubar 高度
 * @returns {Number} navbarState.beforeWidth - before 容器宽度
 * @returns {Number} navbarState.navbarWidth - 实际 navbar 宽度
 * @returns {Number} navbarState.navbarHeight - 实际 navbar 高度
 */
export const useNavbarRect = () => {
  const state = {
    statusBarHeight: 0,
    menubarHeight: 0,
    beforeWidth: 0,
    navbarWidth: 0,
    navbarHeight: 0
  }

  const { statusBarHeight, windowWidth } = uni.getSystemInfoSync()
  state.statusBarHeight = statusBarHeight

  const menubar = uni.getMenuButtonBoundingClientRect()
  state.menubarHeight = menubar.height

  state.beforeWidth = windowWidth - menubar.left

  state.navbarWidth = windowWidth - state.beforeWidth * 2
  state.navbarHeight = Math.abs(2 * (menubar.top + 2 - statusBarHeight)) + menubar.height

  return state
}
